<template>
	<el-date-picker @blur="blur" @focus="changeDate" @input="changeValue" ref="field" class="width-full" :disabled="disabled" :value-format="item.dateType === 1 ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'" :value="value" :type="item.dateType === 1 ? 'date' : 'datetime'" :placeholder="item.hint">
	</el-date-picker>
</template>

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator';
import { dateTime, date } from '@/afterSales/utils/validate'
import widgetCommon from '../common/widgetCommon';
@Component({
  components: {}
})
export default class extends Mixins(widgetCommon) {
  // 配置公式传入不是时间字段时 修改
  private changeDate () {
    const { dateType } = this.item;
    const pattern = dateType === 1 ? date : dateTime;
    if (this.value && !pattern.test(this.value)) {
      this.$emit('input', undefined);
    }
  }
}
</script>

<style lang="stylus" scoped>
.width-full {
	width: 100%
}
</style>
